package main

import (
	"flag"
	"web-app/web-server/internal/config"
	"web-app/web-server/internal/handler"
	"web-app/web-server/internal/log"
	"web-app/web-server/internal/route"
	"web-app/web-server/internal/server"
	"web-app/web-server/internal/types"
)

var (
	configFile = flag.String("config", "/etc/config.yaml", "")
)

func init() {
	route.Register([]types.WebHandler{
		{
			Method: "post",
			Path:   "/login",
			Func:   handler.Login,
		},
	})
}

func main() {
	if !flag.Parsed() {
		flag.Parse()
	}
	cfg, err := config.NewConfig(*configFile)
	if err != nil {
		log.Error("加载配置文件出现错误", err)
		panic(err)
	}
	ws := server.NewWebServer(cfg)
	ws.Start()
}
